/*----------------------------表单页面区域---------------------------------*/
/*--文件路径 src\views\admin\{{ .FileServer }}\{{ .Name }}\components\FormMode.vue----*/
<template>
    <div class="CEshiBox">
        <el-form :inline="true" :model="data.form" label-width="120px">
            <!--/****************************模板修改区域标记********************************************************/-->
            {{range $key, $value := .Fields}}
             <el-form-item label="{{$value.Description}}">
                <el-input v-model="data.form.{{$value.JsonName}}" />
              </el-form-item>
            {{end}}
        </el-form>
    </div>
</template>
/*----------------------------逻辑区域---------------------------------*/
<script setup name="{{ .Name }}FormModle">
import { ref, reactive, getCurrentInstance, onMounted, computed  } from 'vue'
// const { proxy } = getCurrentInstance()
/****************************模板修改区域标记********************************************************/
import {
    api{{ .Name }}Update,
    api{{ .Name }}Creat,
    api{{ .Name }}Read
} from '@/api/{{ .FileApi }}/{{ .Name }}.js'
const data = reactive({
    id: '',
    form: {}
})
const props = defineProps({
    id: {
        type: Number
    }
})
onMounted(() => {
    GetData()
})
const GetData = async() => {
    if (props.id == 0) {
        data.form = {}
    } else {
        /****************************模板修改区域标记********************************************************/
        const res = await api{{ .Name }}Read({ id: props.id })
        if (res.error == '') {
            console.log(res)
            data.form = res.data.form
        }
    }
}
const formUpdate = async() => {
    /****************************模板修改区域标记********************************************************/
    const res = await api{{ .Name }}Update({ 'form': data.form, 'id': props.id })
    return new Promise(function(resolve, reject) {
        // ... some code
        if (res.error == '') {
            resolve(res)
        } else {
            reject(res.error)
        }
    })

}
const formCreat = async() => {
    /****************************模板修改区域标记********************************************************/
    const res = await api{{ .Name }}Creat({ 'form': data.form })
    return new Promise(function(resolve, reject) {
        // ... some code
        if (res.status === 1 && res.error == '') {
            resolve(res)
        } else {
            reject(res.error)
        }
    })

}
defineExpose({
    formCreat, formUpdate
})
</script>
/*----------------------------样式---------------------------------*/
<style lang='scss' scoped>
.CEshiBox {
    width: 100%;
    height: 100%;
}
</style>
